package org.iks.gfs.business.service;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.extension.service.IService;
import org.iks.gfs.business.entity.GfsFileEntity;
import org.iks.gfs.business.vo.GfsFileVo;

/**
 * Author kzou
 * Date 2024/4/6
 * Description:
 */
public interface GfsFileService extends IService<GfsFileEntity> {

    GfsFileVo queryGfsFile(String gfsFileName);

    GfsFileVo queryGfsFileById(Integer id);

    int saveChunkFile(String chunkName, Integer chunkIndex, Integer fileId);

    int saveGfsFile(String originalFilename, String gfsFileName);

    default String saveGfsFile(String originalFilename) {
        String extName = FileUtil.extName(originalFilename);
        String fileName = RandomUtil.randomString(10) + "." + extName;
        saveGfsFile(originalFilename, fileName);
        return fileName;
    }

}
